package com.buka.role.controller;

import com.buka.common.ResultJson;
import com.buka.role.service.RoleService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/role/updateUser")
public class UpdateUser extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //获取参数
        String userid = req.getParameter("userId");
        String roleId = req.getParameter("roleId");

        //调用service 更新用户角色
        RoleService roleService = new RoleService();
        boolean result = roleService.updateUserRole(userid,roleId);
        if(result){
            resp.getWriter().write(ResultJson.success());
        }else{
            resp.getWriter().write(ResultJson.error());
        }
    }
}
